{include file="public/header" /}
<div class="header">
	<span>管理员列表</span>
	<button type="button" class="layui-btn layui-btn-primary layui-btn-sm" onclick="add()">
		<i class="layui-icon layui-icon-add-1"></i>添加
	</button>
	<div></div>
</div>
<table class="layui-table">
	<thead>
		<tr>
			<th>真实姓名</th>
			<th>账户</th>
			<th>手机</th>
			<th>QQ</th>
			<th>角色</th>
			<th>性别</th>
			<th>状态</th>
			<th>登陆次数</th>
			<th>登陆时间</th>
			<th>操作</th>
		</tr>
	</thead>
	<tbody>
		{volist name="lists" id='vo'}
			<tr>
				<td>{$vo.name}</td>
				<td>{$vo.account}</td>
				<td>{$vo.mobile}</td>
				<td>{$vo.qq}</td>
				<td>{:isset($group[$vo.group_id])?$group[$vo.group_id]['group_name']:''}</td>
				<td>
					{if $vo['sex']==1}
						<span style="color:red;">男</span>
					{elseif $vo['sex'] == 2 /}
						<span style="color:green;">女</span>
					{else /}
						未知
					{/if}
				</td>
				<td>{$vo.status==1?'开启':'<span style="color:red;">禁用</span>'}</td>
				<td>{$vo.times_login}</td>
				<td>{:date('Y-m-d H:i:s',$vo.time_last)}</td>
				<td>
					<button type="button" class="layui-btn layui-btn-primary layui-btn-xs" onclick="edit({$vo.uid})">
						<i class="layui-icon layui-icon-edit"></i>编辑
					</button>
					<button type="button" class="layui-btn layui-btn-primary layui-btn-xs" onclick="del({$vo.uid})">
						<i class="layui-icon layui-icon-delete"></i>删除
					</button>
				</td>
			</tr>
		{/volist}
	</tbody>
</table>
<script type="text/javascript">
	layui.use(['layer'],function(){
		layer = layui.layer;
		$ = layui.jquery;
	});
	// 添加
	function add(){
		layer.open({
			type: 2,
			title: '添加管理员',
			shade: 0.3,
			area: ['450px','550px'],
			content: "{$config['admin_route']}bewadmin/useradd"
		});
	}
	// 编辑
	function edit(uid){
		layer.open({
			type: 2,
			title: '编辑管理员',
			shade: 0.3,
			area: ['450px','550px'],
			content: "{$config['admin_route']}bewadmin/useredit?uid="+uid
		});
	}
	// 删除
	function del(uid){
		layer.confirm('确定要删除吗？', {
			icon:3,
			btn: ['确定','取消']
		}, function(){
			$.post("{$config['admin_route']}bewadmin/userdel",{'uid':uid},function(res){
				if(res.code>0){
					layer.alert(res.msg,{icon:2});
				}else{
					layer.msg(res.msg);
					setTimeout(function(){window.location.reload();},1000);
				}
			},'json');
		});
	}
</script>
{include file="public/tail" /}